1. Field of the Invention
The present invention relates to a method, system, and program for generating batch files and, in particular for generating batch files during installation and uninstallation of programs.
2. Description of the Related Art
A batch file or script file is a file that contains a sequence or batch of commands. Batch files are useful for storing sets of commands that are always executed together because the sequence of commands are executed by a single call to the batch file name, instead of entering each command individually. In DOS systems, batch files end with a .BAT extension. Many operating systems use the terms command file or shell script to refer to a batch file. Any valid operating system command may be included in the batch file.
An installation program executing in a particular operating system environment would include a routine to modify or build batch files for use by the installed program set. For installation programs that are designed to install the same program on different operating systems, the installation program developer would have to include in each operating specific installation program a separate operating system specific routine to build or modify batch or script files using the operating system commands. Thus, the installation program developer would have to separately program the installation program to create batch files for each operating system. This process can be significantly tedious if the installation program developer has to write a routine in each operating system specific installation program to build the operating system specific batch files.
There is thus a need in the art for an improved method, system, and program for building batch files to include in an installation program.
To overcome the limitations in the prior art described above, preferred embodiments disclose a system, method, and program for generating a file. An object is processed including a plurality of instructions. Each instruction is associated with at least one executable function. A determination is made of an operating system in which the generated file will be executed. For each instruction in the object, a native operating system command is generated that is capable of executing the function associated with the instruction on the determined operating system. Each generated native operating system command is inserted into the file. Execution of the file on the determined operating system will execute the native operating system commands in the file to perform the functions associated with the instructions included in the object.
In further embodiments, a property associated with the object is processed indicating whether to execute the file after generating the file. The file is executed after being generated if the property indicates to execute the file after being generated. The file is stored in non-volatile memory. Alternatively, the file can be deleted after execution.
In still further embodiments, the file is generated during an installation of a program to include native operating system commands to configure the system for the program being installed. In such case, the file is executed to configure the system to support the program being installed.
In yet further embodiments, a method, system, and program is provided to configure a system during uninstallation of a program to remove files and changes added when the program was uninstalled. During uninstallation, an uninstall object including a plurality of instructions is processed. Each instruction is associated with at least one executable function. A determination is made of an operating system in which the executable functions described in the uninstall object will be executed. For each instruction in the object, a native operating system command is generated that is capable of executing the function associated with the instruction in the determined operating system. Each generated native operating system command is then inserted into a file. The file and native operating system commands therein are then executed to configure the system to reverse changes to the system resulting from the installation of the program.
Preferred embodiments provide a class of data objects and methods which may be used to generate a batch file for processing during installation, uninstallation or other operations. A object would be created defining the sequence of operations to perform in a file generated from the object. The operations specified in the object would be automatically converted to native operating system commands to perform the operations specified in the object. These native operating system commands would then be written to a file that may be stored in the system or used only once during install or uninstall and then deleted.
With preferred embodiments, an installation program developer need only write the batch file once in a preferred embodiment object, and then have the preferred logic automatically generate a file including native operating system commands specified in the data object. In this way, batch files defined once using one set of commands can be used to generate the batch files on different operating systems. Preferred embodiments provide a cross-platform program for installing batch files for use during installation, uninstallation or for other reasons.